﻿<%@ WebHandler Language="C#" Class="userManage" %>

using System;
using System.Web;
using System.Data;
using System.Text;
using System.IO;
using Chenxin.Lib.Utility;
using System.Collections.Generic;

//****************************************************************
//   臣信二手房
//   Copyright (c) 2010 Chenxin.                        
//****************************************************************
//****************************************************************      
//作成者       :  he.jifeng   
//创建日期     :  2010-03-04                 
//確認者       :  確認者          
//功能概要　   :  人事查询
//****************************************************************
public class userManage : AjaxHandlerBase
{

    //*******************************************
    //功能概要       ：重写的请求处理方法
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：父类中隐藏了IHttpHandler接口方法，本类中须对本方法进行重写
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-04 
    //*******************************************
    override public void RequestProcess(HttpContext context)
    {
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";
        
        //处理类型
        string strDealType  = context.Request.Params["op"];

        switch (strDealType)
        {
            case "GetShowContent":
                getShowContent(context);
                break;
            case "GetCondition":
                getCondition(context);
                break;
            case "Search":
                searchUserInfo(context);
                break;
            case "Add":
                addUserInfo(context);
                break;
            case "Del":
                delUserInfo(context);
                break;
            case "GetBaseInfo":
                getUserInfo(context);
                break;
            case "Edit":
                editUserInfo(context);
                break;
            case "GetCount":
                getCount(context);
                break;
            case "pageShow":
                pageShow(context);
                break;
            case "Change":
                UserChange_HR(context);
                break;
            case "Terms":
                TermsOperation(context);
                break;
            case "Virtual":
                AddVirtual(context);
                break;
            case "GetAllCompany":
                getAllCompany(context);
                break;
            case "GetTerms":
                getTerms(context);
                break;
            case "ptOperation":
                ptOperation(context);
                break;
            //case "GetTransferInfo":
            //    getTransferInfo(context);
            //    break;
        }
    }
    
    //职权职务关系操作
    private void ptOperation(HttpContext context)
    {
        string strSql = "";
        string stype = context.Request.Params["stype"];
        int count = 0;
        if (stype == "add")
        {
            string terms = context.Request.Params["terms"];
            string companyid = context.Request.Params["companyid"];
            string pos = context.Request.Params["pos"];
            string[] array = pos.Split(',');
            foreach (string s in array)
            {
                strSql += string.Format("insert into HR_Rel_Office values(newid(),'{0}','{1}','{2}',getdate());",terms,s,companyid);
            }
            count = array.Length;
        }
        if (stype == "del")
        {
            string recordid = context.Request.Params["recordid"];
            strSql = string.Format("delete from HR_Rel_Office where RecodID='{0}'", recordid);
        }

        bool flag = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.ExecuteSQL(strSql);
        if (flag)
            context.Response.Write("{success:'1',txt:'"+count+"'}");
        else
            context.Response.Write("{success:'0',txt:'操作失败!'}");
    }
    
    //根据条件得到相应的职务
    private void getTerms(HttpContext context)
    {
        string companyid = context.Request.QueryString["companyid"];
        string str = "";
        
        if (companyid == "0")
            context.Response.Write("");
        else {
            string strSql = string.Format("ItemKey= 'System.Position' and ItemValue not in (select OfficeName from Chenxin_Main.dbo.HR_Rel_Office where CompanyID='{0}') and CompanyID='{1}'",companyid,companyid);
            DataSet ds = Chenxin.Lib.House.DAL.DataDictionary.GetList(strSql,"");
            if (ds.Tables.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        str += string.Format("{{ txt: '{0}', val: '{1}' }},", dr["ItemValue"].ToString(), dr["ItemValue"].ToString());
                    }
                    str = str.Substring(0, str.Length - 1);
                }
                else
                    str = "";
            }
            context.Response.Write(str);
        }
    }
    
    //得到所有公司
    private void getAllCompany(HttpContext context)
    {
        List<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo> list = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetListArray("DepartProperty=200");
        
        //生成JSON字符串
        System.Text.StringBuilder str = new System.Text.StringBuilder();

        foreach (Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo item in list)
        {
            str.Append(", { txt: '" + item.DepartName.Trim() + "', val: '" + item.DepartId + "' }");
        }
        context.Response.Write(str.ToString());
    }
    
    
    //*******************************************
    //功能概要       ：添加虚账号
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：添加虚账号
    //作成者         ：薛彦 
    //作成日         ：2010-04-07
    //*******************************************
    private void AddVirtual(HttpContext context)
    {
        try
        {

            //用户基本信息业务类
            Chenxin.Lib.Passport.BLL.Hr_UserInfo bllUserInfo = new Chenxin.Lib.Passport.BLL.Hr_UserInfo();
            //用户基本信息实体类
            Chenxin.Lib.Passport.Entity.Hr_UserInfo entUserInfo =
            (Chenxin.Lib.Passport.Entity.Hr_UserInfo)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.Passport.Entity.Hr_UserInfo));
           
            entUserInfo.ComeDate = DateTime.Now;

            //是否冻结
            entUserInfo.Validate = false;

            //密码（暂时固定）
            entUserInfo.Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("111", "MD5");
            //姓名品应首字母
            entUserInfo.Initial = Chenxin.Lib.Utility.InitialHelper.GetChineseSpell(entUserInfo.UserName).Substring(0, 1);
            //是否虚拟账号
            entUserInfo.IsVirtual = true;
            //员工编号
            string usercode = Chenxin.Lib.Passport.BLL.Hr_UserInfo.GetUserCode(Guid.Empty, "CXSH_X");
            entUserInfo.UserCode = usercode;
            //流水号
            entUserInfo.SerialCode = entUserInfo.UserCode.Replace("CXSH_X", "");
            entUserInfo.Status = 1;
            entUserInfo.Sex = 0;
            entUserInfo.UserId = Guid.NewGuid();
            entUserInfo.UserType = 0;

            bllUserInfo.Add(entUserInfo);

            context.Response.Write(retExecResult(Constants.ExecResult.Succ, "添加成功", ""));
        }
        catch (Exception ex)
        {
            context.Response.Write(retExecResult(Constants.ExecResult.Error, ex.Message, ""));
        }
        
    }
    
    
    //*******************************************
    //功能概要       ：员工职权设定
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：员工职权设定
    //作成者         ：薛彦 
    //作成日         ：2010-04-07
    //*******************************************
    private void TermsOperation(HttpContext context)
    {
        //类型
        string stype = context.Request.Params["stype"];
        if (stype == "add")
        {
            //用户ID
            string userid = context.Request.Params["userid"];
            //用户姓名
            string username = context.Request.Params["username"];
            //部门ID
            string depid = context.Request.Params["depid"];
            //部门名称
            string depname = context.Request.Params["depname"];
            //职权类型
            string roletype = context.Request.Params["roletype"];
            //开始时间
            DateTime comedate = DateTime.Parse(context.Request.Params["comedate"].ToString());
            
            string strSql=string.Format("insert into Hr_Struct_UserDepartRelation(RecordId,DepartId,DepartName,UserId,UserName,IsBelong,ComeDate,RoleType,Addtime) values(newid(),'{0}','{1}','{2}','{3}','0','{4}','{5}',getdate());",depid,depname,userid,username,comedate,roletype);

            bool flag = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.ExecuteSQL(strSql);
            if (flag)
                context.Response.Write("{success:'1'}");
            else
                context.Response.Write("{success:'0',txt:'操作失败!'}");
        }
        else if (stype == "del")
        {
            //记录ID
            string recordid = context.Request.Params["recordid"];
            //结束时间
            DateTime endtime =DateTime.Parse(context.Request.Params["endtime"].ToString());
            if (Chenxin.Lib.Passport.BLL.Hr_UserInfo.CheckTime(recordid, endtime, 2))
            {
                string strSql = "";
                strSql += string.Format("insert into Hr_Struct_UserDepartRelation_History select RecordId,DepartId,DepartName,UserId,UserName,IsBelong,ComeDate,'{0}',RoleType,Addtime from Hr_Struct_UserDepartRelation where RecordId='{1}';", endtime, recordid);
                strSql += string.Format("delete from Hr_Struct_UserDepartRelation where RecordId='{0}';", recordid);

                bool flag = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.ExecuteSQL(strSql);

                if (flag)
                    context.Response.Write("{success:'1'}");
                else
                    context.Response.Write("{success:'0',txt:'操作失败!'}");
            }
            else
                context.Response.Write("{success:'0',txt:'结束时间早于开始时间，请重新输入结束时间!'}");
        }
        
    }

    //*******************************************
    //功能概要       ：员工人事变动
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：员工人事变动
    //作成者         ：薛彦 
    //作成日         ：2010-04-06
    //*******************************************
    private void UserChange_HR(HttpContext context)
    {
        try
        {
            //用户基本信息实体类
            Chenxin.Lib.Passport.Entity.Hr_ChangeUserHR clpehcyr =
            (Chenxin.Lib.Passport.Entity.Hr_ChangeUserHR)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.Passport.Entity.Hr_ChangeUserHR));

            //用户ID
            string userid = clpehcyr.UserId.ToString();
            //部门ID(变动至)
            string depid = clpehcyr.DepartId.ToString();
            if (depid == "")
                depid = Guid.Empty.ToString();
            //部门名称（变动至）
            string depname = clpehcyr.DepartName;
            //变动类型
            string type = clpehcyr.TransType;
            //变动类型序号
            string typeid = clpehcyr.TransTypeId;
            //变动日期
            DateTime datetime = (DateTime)clpehcyr.TransTime;
            //变动职务
            string Position = "";
            if (!string.IsNullOrEmpty(clpehcyr.Position))
                Position = clpehcyr.Position;
            //变动职级
            string Level = "";
            if (!string.IsNullOrEmpty(clpehcyr.Level))
                Level = clpehcyr.Level;
            //变动理由
            string Reason = clpehcyr.TransReason;

            //操作类型
            int OperateType = 0;

            Chenxin.Lib.Passport.BLL.Hr_UserInfo bllUserInfo = new Chenxin.Lib.Passport.BLL.Hr_UserInfo();

            //离职或调休
            if (typeid == "1" || typeid == "7")
                OperateType = 2;
            else if (typeid == "4")
                OperateType = 3;
            else if (typeid == "2" || typeid == "3")
                OperateType = 4;
            else
                OperateType = 5;

            if (Chenxin.Lib.Passport.BLL.Hr_UserInfo.CheckTime(userid, datetime, 1))
            {
                string setting = Chenxin.Lib.Passport.BLL.Hr_UserInfo.UserSetting(userid, OperateType, type, Reason, datetime, CurrentUserInfo.UserName, new Guid(depid), depname, Position, Level);
                context.Response.Write(retExecResult(Constants.ExecResult.Succ, "变动成功！", ""));
            }
            else
            {
                context.Response.Write(retExecResult(Constants.ExecResult.Error, "变动日期小于开始日期，请重新选择变动日期！", ""));
            }
        }
        catch (Exception ex)
        {
            context.Response.Write(retExecResult(Constants.ExecResult.Error, ex.Message, ""));
        }
    }

    //*******************************************
    //功能概要       ：获得人事档案分页数据
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：获得人事档案分页数据
    //作成者         ：薛彦 
    //作成日         ：2010-03-31
    //*******************************************
    private void pageShow(HttpContext context)
    {
        int pageindex = 0;//页码
        int PageSize = 0;//页显示行数
        string strwhere = "";
        string stype="";
        DataSet ds = new DataSet();
        //页码        
        if (!string.IsNullOrEmpty(context.Request.QueryString["pageIndex"]))
        {
            pageindex = int.Parse(context.Request.QueryString["pageIndex"]) + 1;
        }
        //页显示行数
        if (!string.IsNullOrEmpty(context.Request.QueryString["pageRow"]))
        {
            PageSize = int.Parse(context.Request.QueryString["pageRow"]);
        }
        string userid = "";
        if (!string.IsNullOrEmpty(context.Request.QueryString["UserId"]))
        {
            userid = context.Request.QueryString["UserId"];
        }
        
        stype=context.Request.QueryString["stype"];
        System.Text.StringBuilder str = new System.Text.StringBuilder();

        if (stype == "terms")
        {strwhere = string.Format("UserId='{0}'", userid);
            
            ds = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.GetList(pageindex, PageSize, "Hr_Struct_UserDepartRelation.AddTime desc", "Hr_Struct_UserDepartRelation", strwhere, "RecordId,DepartName,IsBelong,RoleType,ComeDate", "RecordId,DepartName,case IsBelong when 'True' then '√' end,case RoleType when '1' then '业务员'  when '2' then '店长'  when '3' then '高经'  when '4' then '区经'  when '5' then '商经' end,Convert(varchar(10),ComeDate,120) as ComeDate", true);

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string click_str = "";
                if (ds.Tables[0].Rows[i][2].ToString().Trim() == "√")
                    click_str = "onclick=\"del_Terms('0')\"";
                else
                    click_str = string.Format("onclick=\"del_Terms('{0}')\"", ds.Tables[0].Rows[i][0]);
                string td = "";
                td = String.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td><a href='#' {4} >删除</a></td></tr>", ds.Tables[0].Rows[i][1], ds.Tables[0].Rows[i][2], ds.Tables[0].Rows[i][3], ds.Tables[0].Rows[i][4], click_str);
                str.Append(td);
            }
        }
        else if (stype == "pt")
        {
            if (!string.IsNullOrEmpty(context.Request.Params["PostName"]))
                strwhere += string.Format("PostName='{0}' and ", context.Request.Params["PostName"]);
            if (!string.IsNullOrEmpty(context.Request.Params["CompanyID"]))
                strwhere += string.Format("HR_Rel_Office.CompanyID='{0}' and ", context.Request.Params["CompanyID"]);

            strwhere += string.Format("HR_Rel_Office.CompanyID = Hr_DepartmentInfo.DepartId");

            ds = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.GetList(pageindex, PageSize, "HR_Rel_Office.AddTime desc", "HR_Rel_Office,Hr_DepartmentInfo", strwhere, "RecodID,PostName,OfficeName,DepartName", "RecodID,PostName,OfficeName,DepartName", true);

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string td = "";
                td = String.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td><a href='#' onclick=\"del_pt('{3}')\" >删除</a></td></tr>", ds.Tables[0].Rows[i][1], ds.Tables[0].Rows[i][2], ds.Tables[0].Rows[i][3], ds.Tables[0].Rows[i][0]);
                str.Append(td);
            }
        }
        
        context.Response.Write(str.ToString());         
        
    }
    
    //*******************************************
    //功能概要       ：获得人事档案记录总数
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：获得人事档案记录总数
    //作成者         ：薛彦 
    //作成日         ：2010-03-31
    //*******************************************
    private void getCount(HttpContext context)
    {
        string userid = context.Request.Params["UserId"];
        string stype = context.Request.Params["stype"];
        DataSet ds = new DataSet();
        string strwhere = "";
        if (stype == "terms")
        {
            strwhere = string.Format("UserId='{0}'", userid);
            ds = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.GetList(1, 1, "AddTime desc", "Hr_Struct_UserDepartRelation", strwhere, "*", "*", false);
        }
        else if (stype == "pt")
        {
            if (!string.IsNullOrEmpty(context.Request.QueryString["PostName"]))
                strwhere += string.Format("PostName='{0}' and ", context.Request.QueryString["PostName"]);
            if (!string.IsNullOrEmpty(context.Request.QueryString["CompanyID"]))
                strwhere += string.Format("CompanyID='{0}' and ", context.Request.QueryString["CompanyID"]);
            if (strwhere.Length > 0)
                strwhere = strwhere.Substring(0, strwhere.Length - 5);
            else
                strwhere = "1=1";
            ds = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.GetList(1, 1, "AddTime desc", "HR_Rel_Office", strwhere, "*", "*", false);
        }
        System.Text.StringBuilder str = new System.Text.StringBuilder();
        str.Append("{count:'" + ds.Tables[0].Rows[0][0].ToString() + "'}");
        context.Response.Write(str.ToString()); 
    }    
        
    
    //*******************************************
    //功能概要       ：获得人事查询的操作页面内容（Html）
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：获得人事查询的操作页面内容（Html）
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-04 
    //*******************************************
    private void getShowContent(HttpContext context)
    {
        //响应结果
        StringBuilder strHtml = new StringBuilder();

        try
        {
            ////查询条件
            //strHtml.Append("<div id='house_search'>");
            //strHtml.Append("	<div class='title_box'>");
            //strHtml.Append("		<div class='search_tit'>员工信息查询</div>");
            //strHtml.Append("	</div>");
            //strHtml.Append("	<div class='search_group'>");
            //strHtml.Append("		<div style='float:left; width:720px;'>");
            //strHtml.Append("			<ul>");
            //strHtml.Append("					<li>条件：</li>");
            //strHtml.Append("					<li  style='width:110px;'>");
            //strHtml.Append("<div id='divSearchMatch' class='selectnav' style='z-index:902;'>");
            //strHtml.Append("						<input id='txtCondition' class='inputbox_n fl' type='text'  style='width:100px;' onblur='javascript:setSearchMatch();'/>");
            //strHtml.Append("<dl style='width:300px; display:none;' id='dlSearchMatch'>");
            //strHtml.Append("</dl>");
            //strHtml.Append("</div>");
            //strHtml.Append("					</li>");
            //strHtml.Append("					<li>工号：</li>");
            //strHtml.Append("					<li style='width:90px;'>");
            //strHtml.Append("						<input id='txtUserCode' class='inputbox_n fl' type='text'  style='width:80px;'/>");
            //strHtml.Append("					</li>");
            //strHtml.Append("					<li>状态：</li>");
            //strHtml.Append("					<li style='width:90px;'>");
            //strHtml.Append("						<div class='SelectWrapSingle' id='divStatus'>");
            //strHtml.Append("						</div>");
            //strHtml.Append("					</li>");
            //strHtml.Append("					<li>到职时间：</li>");
            //strHtml.Append("					<li style='width:75px;'>");
            //strHtml.Append("						<input id='txtComeDateFrom' class='inputbox_n fl' type='text' style='width:70px;'/>");
            //strHtml.Append("					<li style='width:15px; text-align:center'>");
            //strHtml.Append("					-");
            //strHtml.Append("					</li>");
            //strHtml.Append("					<li style='width:85px;'>");
            //strHtml.Append("						<input id='txtComeDateTo' class='inputbox_n fl' type='text' style='width:70px;'/>");
            //strHtml.Append("					</li>"); 
            //strHtml.Append("					<li style='width:70px;'><input id='btSreachUserInfo' type='button'  class='btn_s_0'/></li>");
            //strHtml.Append("			</ul>");
            //strHtml.Append("		</div>");
            //strHtml.Append("		<div style='float:left; margin-left:8px;' class='btn-slide'></div>");
            //strHtml.Append("		<div style='float:left; width:725px; padding:5px 0px;' id='panel'>");
            //strHtml.Append("			<ul>");  
            //strHtml.Append("				<li>合同时间：</li>");
            //strHtml.Append("				<li style='width:85px;'>");
            //strHtml.Append("					<input id='txtContractDateFrom' class='inputbox_n fl' type='text' style='width:80px;'/>");
            //strHtml.Append("				</li>");
            //strHtml.Append("				<li style='width:15px; text-align:center'>");
            //strHtml.Append("				-");
            //strHtml.Append("				</li>");
            //strHtml.Append("				<li style='width:95px;'>");
            //strHtml.Append("					<input id='txtContractDateTo' class='inputbox_n fl' type='text' style='width:80px;'/>");
            //strHtml.Append("				</li>"); 
            //strHtml.Append("				<li>离职时间：</li>");
            //strHtml.Append("				<li style='width:85px;'>");
            //strHtml.Append("					<input id='txtLeaveDateFrom' class='inputbox_n fl' type='text' style='width:80px;'/>");
            //strHtml.Append("				<li style='width:15px; text-align:center'>");
            //strHtml.Append("				-");
            //strHtml.Append("				</li>");
            //strHtml.Append("				</li>");
            //strHtml.Append("				<li style='width:95px;'>");
            //strHtml.Append("					<input id='txtLeaveDateTo' class='inputbox_n fl' type='text' style='width:80px;'/>");
            //strHtml.Append("				</li>"); 
            //strHtml.Append("				<li>身份证号：</li>");
            //strHtml.Append("				<li style='width:120px;'>");
            //strHtml.Append("					<input id='txtIDNo' class='inputbox_n fl' type='text' style='width:110px;'/>");
            //strHtml.Append("				</li>");
            //strHtml.Append("				<li>角色：</li>");
            //strHtml.Append("				<li style='width:100px;'>");
            //strHtml.Append("					<div class='SelectWrapSingle' id='divRole'>");
            //strHtml.Append("					</div>");
            //strHtml.Append("				</li>");
            //strHtml.Append("				<li>职务：</li>");
            //strHtml.Append("				<li>");
            //strHtml.Append("					<div class='SelectWrapSingle' id='divPosition'>");
            //strHtml.Append("					</div>");
            //strHtml.Append("				</li>");                
            //strHtml.Append("			</ul>");	  
            //strHtml.Append("		</div>");
            //strHtml.Append("	</div>");
            //strHtml.Append("	<div style='font: 0px/0px sans-serif;clear: both;display: block'></div>");
            //strHtml.Append("</div>");
            //strHtml.Append("<input type='hidden' id='hidConditionId' />");
            //strHtml.Append("<input type='hidden' id='hidConditionNm' />");
            //strHtml.Append("<input type='hidden' id='hidConditionType' />");
            
            ////操作区域和内容显示
            //strHtml.Append("<div class='search_table'>");
            //strHtml.Append("	<div class='search_table_title'>");
            //strHtml.Append("		<h2>员工信息列表</h2>");
            //strHtml.Append("		<div style='width:180px'>");
            //strHtml.Append("			<a href='#' class='simple' title='生日模式' id='aTypeBorn'>生日模式</a>");
            //strHtml.Append("			<a href='#' class='detailed' title='人事资料模式' id='aTypePersonnel'>人事资料模式</a>");
            //strHtml.Append("		</div>");
            //strHtml.Append("	</div>");
            //strHtml.Append("	<div class='op_button'>");
            //strHtml.Append("		<div class='btn btn2'><a href='#' title='人员添加' id='aAddUser'><span>人员添加</span></a></div>");
            //strHtml.Append("		<div class='btn btn2'><a href='#' title='基本信息' id='aEditBaseInfo'><span>基本信息</span></a></div>");
            //strHtml.Append("		<div class='btn btn2'><a href='#' title='人事变动' id='aChgPersonnel'><span>人事变动</span></a></div>");
            //strHtml.Append("		<div class='btn btn2'><a href='#' title='职权变更' id='aEditScope'><span>职权变更</span></a></div>");
            //strHtml.Append("		<div class='btn btn2'><a href='#' title='预览' id='aReview'><span>预览</span></a></div>");
            //strHtml.Append("		<div class='btn btn2'><a href='#' title='删除' id='aDelUser'><span>删除</span></a></div>");
            //strHtml.Append("	</div>");

            ////数据显示
            //strHtml.Append("    <div id='tab_div_inbox3'>");
            //strHtml.Append("	    <table id='jqGridBirthday'></table>");
            //strHtml.Append("	    <div id='jqPageBirthday'></div>");
            //strHtml.Append("    </div>");
            //strHtml.Append("</div>");
            
            ////用户基本信息编辑弹出层
            //strHtml.Append("<form action='' method='post' name='formUserInfo'>");
            //strHtml.Append("<div class='jqmWindow' id='divPopUpUserInfo' style='width: 720px; '>");
            //strHtml.Append("	<div class='jqmTitle jqDrag'>");
            //strHtml.Append("		<span class='title'>人员基本信息编辑</span><span class='jqmClose'></span>");
            //strHtml.Append("	</div>");
            //strHtml.Append("	<table class='tbl_f' width='100%' ");
            //strHtml.Append("	  <tr>");
            //strHtml.Append("	    <th width='95'>工号：<span class='isfilled'>*</span></th>");
            //strHtml.Append("	    <td width='290'><input name='工号' id='UserCode' class='inputbox_n fl' type='text' style='width:92px;' maxlength='20'/>");
            //strHtml.Append("			    <div id='UserCodeTip' style='float: left; margin-left: 5px; width: 120px; height: 26px; line-height: 26px; text-align: left;' class='fl'></td>");
            //strHtml.Append("	    <th width='91'>姓名：<span class='isfilled'>*</span></th>");
            //strHtml.Append("	    <td width='246'><input name='姓名' id='UserName' class='inputbox_n fl' type='text' style='width:92px;' maxlength='50'/>");
            //strHtml.Append("			    <div id='UserNameTip' style='float: left; margin-left: 5px; width: 120px; height: 26px; line-height: 26px; text-align: left;' class='fl'></td>");
            //strHtml.Append("		</tr>");
            //strHtml.Append("		<tr>");
            //strHtml.Append("		  <th>性别：</th>");
            //strHtml.Append("		  <td><div id='divSex' name='性别' class='SelectWrapSingle validator' style='z-index : 103;'></div></td>");
            //strHtml.Append("		  <th>用户类型：</th>");
            //strHtml.Append("		  <td><div id='divUserType' class='SelectWrapSingle' style='z-index : 103;'></div></td>");
            //strHtml.Append("		</tr>");
            //strHtml.Append("		<tr>");
            //strHtml.Append("    	<th>证件类型：</th>");
            //strHtml.Append("	    <td><div class='SelectWrapSingle' id='divIDType' style='z-index : 102;'>");
            //strHtml.Append("	     </div></td>");
            //strHtml.Append("	    <th>证件号码：</th>");
            //strHtml.Append("	    <td><input name='IDNo' id='IDNo' class='inputbox_n fl' type='text' style='width:92px;' maxlength='80'/>");
            //strHtml.Append("	    </td>");
            //strHtml.Append("		</tr>");
            //strHtml.Append("   		<tr>");
            //strHtml.Append("   			<th>城市：</th>");
            //strHtml.Append("   			<td><div class='SelectWrapSingle validator' name='城市' id='divCity' style='z-index : 101;'></div>");
            //strHtml.Append("   			 </td>");
            //strHtml.Append("   			<th>出生年月：</th>");
            //strHtml.Append("   			<td>");
            //strHtml.Append("   				<input name='BirthDay' id='BirthDay' class='inputbox_n fl' type='text' style='width:80px;'/>");
            //strHtml.Append("   			</td>");
            //strHtml.Append("   		</tr>");
            //strHtml.Append("   		<tr>");
            //strHtml.Append("   			<th>教育程度：</th>");
            //strHtml.Append("   			<td>");
            //strHtml.Append("   				<div class='SelectWrapSingle' id='divEducation' style='z-index : 100;'></div>");
            //strHtml.Append("   			 </td>");
            //strHtml.Append("   			<th>所属部门：</th>");
            //strHtml.Append("   			<td>");
            //strHtml.Append("   				<div class='SelectWrapSingle validator' name='所属部门' id='divDepartId' style='z-index : 100;'></div>");
            //strHtml.Append("   			</td>");
            //strHtml.Append("   		</tr>");
            //strHtml.Append("		<tr>");
            //strHtml.Append("			<th>手机：</th>");
            //strHtml.Append("			<td><input name='Mobile' id='Mobile' class='inputbox_n fl' type='text' style='width:92px;' maxlength='50' />");
            ////strHtml.Append("			    <div id='MobileTip' style='float: left; margin-left: 5px; width: 120px; height: 26px; line-height: 26px; text-align: left;' class='fl'>");
            //strHtml.Append("			 </td>");
            //strHtml.Append("			<th>家庭电话：</th>");
            //strHtml.Append("			<td><input name='HomeTel' id='HomeTel' class='inputbox_n fl' type='text' style='width:92px;' maxlength='50' />");
            //strHtml.Append("			</td>");
            //strHtml.Append("		</tr>");
            //strHtml.Append("   		<tr>");
            //strHtml.Append("   			<th>工作电话：</th>");
            //strHtml.Append("   			<td>");
            //strHtml.Append("   				<input name='OfficeTel' id='OfficeTel' class='inputbox_n fl' type='text' style='width:92px;'  maxlength='50' />");
            //strHtml.Append("   			 </td>");
            //strHtml.Append("   			<th>工资账号：</th>");
            //strHtml.Append("   			<td>");
            //strHtml.Append("   				<input name='BankNo' id='BankNo' class='inputbox_n fl' type='text' style='width:92px;'  maxlength='50'/>");
            //strHtml.Append("   			</td>");
            //strHtml.Append("   		</tr>");
            //strHtml.Append("   		<tr>");
            //strHtml.Append("   			<th>公积金账户：</th>");
            //strHtml.Append("   			<td>");
            //strHtml.Append("   				<input name='FundCode' id='FundCode' class='inputbox_n fl' type='text' style='width:92px;'  maxlength='50' />");
            //strHtml.Append("   			 </td>");
            //strHtml.Append("   			<th>到职日期：</th>");
            //strHtml.Append("   			<td>");
            //strHtml.Append("   				<input name='ComeDate' id='ComeDate' class='inputbox_n fl' type='text' style='width:80px;'/>");
            //strHtml.Append("   			 </td>");
            //strHtml.Append("   		</tr>");
            //strHtml.Append("   		<tr>");
            //strHtml.Append("   			<th>职级：</th>");
            //strHtml.Append("   			<td>");
            //strHtml.Append("   				<div class='SelectWrapSingle' id='divEmpLevel' style='z-index : 99;'></div>");
            //strHtml.Append("   			 </td>");
            //strHtml.Append("   			<th>职务：</th>");
            //strHtml.Append("   			<td>");
            //strHtml.Append("   				<div class='SelectWrapSingle' id='divEditPosition' style='z-index : 99;'></div>");
            //strHtml.Append("   			</td>");
            //strHtml.Append("   		</tr>");
            //strHtml.Append("   		<tr>");
            //strHtml.Append("   			<th>是否冻结：</th>");
            //strHtml.Append("   			<td colspan='3'><input name='Validate' id='Validate' value='true' class='inputbox_n fl' type='checkbox' style='width:80px;'/>");
            //strHtml.Append("   			</td>");
            //strHtml.Append("   		</tr>");
            //strHtml.Append("		<tr>");
            //strHtml.Append("			<th>联系地址：</th>");
            //strHtml.Append("			<td colspan='3'><input name='Address' id='Address' class='inputbox_n fl' type='text' style='width:522px;'  maxlength='100'/></td>");
            //strHtml.Append("		</tr>");
            //strHtml.Append("   		<tr>");
            //strHtml.Append("   			<th>备注：</th>");
            //strHtml.Append("   			<td colspan='3'>");
            //strHtml.Append("   				<input name='Remark' id='Remark' class='inputbox_n fl' type='text' style='width:522px;'/>");
            //strHtml.Append("   			</td>");
            //strHtml.Append("   		</tr>");
            //strHtml.Append("	</table>");
            //strHtml.Append("	<table width='723px' border='0' cellspacing='0' cellpadding='0'>");
            //strHtml.Append("		<tr>");
            //strHtml.Append("    	<td height='51'>");
            //strHtml.Append("    		<div class='alg_center' style='float:right;'>");
            //strHtml.Append("					<a id='aSubmitAddUser' class='btn_n fl'  ><span>提交</span></a>");
            //strHtml.Append("					<a id='aCloseAddUser' class='btn_n fl' ><span>关闭</span></a></div>");
            //strHtml.Append("			</td>");
            //strHtml.Append("		</tr>");
            //strHtml.Append("	</table>");
            //strHtml.Append("</div>");
            //strHtml.Append("</form>");

            ////人事变动弹出层
            //strHtml.Append("<div class='jqmWindow' id='divPopUpChgPersonnel' style='width: 720px; '>");
            //strHtml.Append("	<div class='jqmTitle jqDrag'>");
            //strHtml.Append("		<span class='title'>人事变动</span><span class='jqmClose'></span>");
            //strHtml.Append("	</div>");
            //strHtml.Append("	<table  class='tbl_f' width='100%'>");
            //strHtml.Append("	  <tr>");
            //strHtml.Append("	    <th>用户ID：</th>");
            //strHtml.Append("	    <td>&nbsp;</td>");
            //strHtml.Append("	    <th>用户名：</th>");
            //strHtml.Append("	    <td>&nbsp;</td>");
            //strHtml.Append("	    <td>&nbsp;</td>");
            //strHtml.Append("	    <td>&nbsp;</td>");
            //strHtml.Append("	  </tr>");
            //strHtml.Append("	  <tr>");
            //strHtml.Append("	    <th>原部门：</th>");
            //strHtml.Append("	    <td>&nbsp;</td>");
            //strHtml.Append("	    <th>原职务：</th>");
            //strHtml.Append("	    <td>&nbsp;</td>");
            //strHtml.Append("	    <th>原等级：</th>");
            //strHtml.Append("	    <td>&nbsp;</td>");
            //strHtml.Append("	  </tr>");
            //strHtml.Append("	  <tr>");
            //strHtml.Append("	    <th>新部门：</th>");
            //strHtml.Append("	    <td><div class='SelectWrapSingle'><!--下拉列表-->");
            //strHtml.Append("	    <h6 style='width:45px;'>请选择</h6><h5></h5>");
            //strHtml.Append("	     </div></td>");
            //strHtml.Append("	    <th>新职务：</th>");
            //strHtml.Append("	    <td><div class='SelectWrapSingle'><!--下拉列表-->");
            //strHtml.Append("	    <h6 style='width:45px;'>请选择</h6><h5></h5>");
            //strHtml.Append("	     </div></td>");
            //strHtml.Append("	    <th>新等级：</th>");
            //strHtml.Append("	    <td><div class='SelectWrapSingle'><!--下拉列表-->");
            //strHtml.Append("	    <h6 style='width:45px;'>请选择</h6><h5></h5>");
            //strHtml.Append("	     </div></td>");
            //strHtml.Append("	  </tr>");
            //strHtml.Append("	   <tr>");
            //strHtml.Append("	    <th>变动类型：</th>");
            //strHtml.Append("	    <td><div class='SelectWrapSingle'><!--下拉列表-->");
            //strHtml.Append("	    <h6 style='width:45px;'>请选择</h6><h5></h5>");
            //strHtml.Append("	     </div></td>");
            //strHtml.Append("	    <th>变动原因：</th>");
            //strHtml.Append("	    <td><div class='SelectWrapSingle'><!--下拉列表-->");
            //strHtml.Append("	    <h6 style='width:45px;'>请选择</h6><h5></h5>");
            //strHtml.Append("	     </div></td>");
            //strHtml.Append("	    <th>变动日期：</th>");
            //strHtml.Append("	    <td><input name='' class='inputbox_n fl' type='text' style='width:92px;'/></td>");
            //strHtml.Append("	  </tr>");
            //strHtml.Append("	</table>");
            //strHtml.Append("</div>");
            //strHtml.Append("<input type='hidden' id='hidSelectedUser' />");
            //strHtml.Append("<input type='hidden' id='hidDealType' />");
            
            //权限下拉框值
            string strLsPermits = getAllRoles();
            //部门下拉框值
            string strLsDeparts = getAllDeparts();
            //城市下拉框值
            string strLsCitys = getAllCitys();
            //职级
            string strLsPosition = getAllPosition();
            //职称
            string strLsEmpLevel = getAllEmpLevel();
            string strCityId=GetCompanyByCity(context.Request["CityId"]);
            
            
            //响应内容
            context.Response.Write(JsonHelper<string>.WriteObject("SUCCESS", strHtml.ToString() + "@" + strLsPermits + "@" + strLsDeparts + "@" + strLsCitys + "@" + strLsPosition + "@" + strLsEmpLevel + "@" + strCityId));
        }
        catch(Exception ex)
        {
            //错误信息回传
            context.Response.Write(JsonHelper<string>.WriteObject("ERROR", ex.Message));
        }
    }

    //*******************************************
    //功能概要       ：得到所有角色
    //参数説明       ：context 请求的上下文
    //返回值説明     ：角色列表所需的json数据
    //功能詳細       ：得到所有角色
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-04 
    //*******************************************
    private string getAllRoles()
    {
        //业务角色类
        Chenxin.Lib.Hr.BLL.Base_Permit_RoleDefine bllBasePermitRoleDefine = new Chenxin.Lib.Hr.BLL.Base_Permit_RoleDefine();
        
        //json数据
        string strJson = "{ txt: '请选择', val: '0' }";
        
        //权限类
        List<Chenxin.Lib.Hr.Entity.Base_Permit_RoleDefine> lsRoles = bllBasePermitRoleDefine.GetAllList();
            
        //循环列表
        for (int idxCnt = 0; idxCnt < lsRoles.Count; idxCnt++)
        {
            strJson = strJson + ",{ txt: '";
            strJson = strJson + lsRoles[idxCnt].RoleName;
            strJson = strJson + "', val: '";
            strJson = strJson + lsRoles[idxCnt].RoleId.ToString();
            strJson = strJson + "' }";
        }

        return strJson;
    }

    //*******************************************
    //功能概要       ：得到部门
    //参数説明       ：context 请求的上下文
    //返回值説明     ：部门列表所需的json数据
    //功能詳細       ：得到部门
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-08 
    //*******************************************
    private string getAllDeparts()
    {
        //业务角色类
        Chenxin.Lib.Hr.BLL.Hr_DepartmentInfo bllHrDepartmentInfo = new Chenxin.Lib.Hr.BLL.Hr_DepartmentInfo();
        
        //json数据
        string strJson = "{ txt: '请选择', val: '0' }";

        //权限类
        List<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo> lsDeparts = bllHrDepartmentInfo.GetAllDeparts();

        //循环列表
        for (int idxCnt = 0; idxCnt < lsDeparts.Count; idxCnt++)
        {
            strJson = strJson + ",{ txt: '";
            strJson = strJson + lsDeparts[idxCnt].DepartName;
            strJson = strJson + "', val: '";
            strJson = strJson + lsDeparts[idxCnt].DepartId.ToString();
            strJson = strJson + "' }";
        }

        return strJson;
    }

    private string getAllCitys()
    {
        //业务角色类
        Chenxin.Lib.Hr.BLL.Struct_CityBaseInfo bllCityBaseInfo = new Chenxin.Lib.Hr.BLL.Struct_CityBaseInfo();

        //json数据
        string strJson = "{ txt: '请选择', val: '0' }";
        
        List<Chenxin.Lib.Hr.Entity.Struct_CityBaseInfo> lsCitys = bllCityBaseInfo.GetModelList("");
        //循环列表
        for (int idxCnt = 0; idxCnt < lsCitys.Count; idxCnt++)
        {
            strJson = strJson + ",{ txt: '";
            strJson = strJson + lsCitys[idxCnt].CityName;
            strJson = strJson + "', val: '";
            strJson = strJson + lsCitys[idxCnt].CityId.ToString();
            strJson = strJson + "' }";
        }

        return strJson;
    }

    private string getAllPosition()
    {
        //业务角色类
        Chenxin.Lib.House.BLL.DataDictionary bllDic = new Chenxin.Lib.House.BLL.DataDictionary();

        //json数据
        string strJson = "{ txt: '请选择', val: '0' }";

        List<Chenxin.Lib.House.Entity.DataDictionary> lsPosition = bllDic.GetDicList("System.Position", CurrentUserInfo.CityId);
        //循环列表
        for (int idxCnt = 0; idxCnt < lsPosition.Count; idxCnt++)
        {
            strJson = strJson + ",{ txt: '";
            strJson = strJson + lsPosition[idxCnt].ItemValue;
            strJson = strJson + "', val: '";
            strJson = strJson + lsPosition[idxCnt].ItemValue;
            strJson = strJson + "' }";
        }

        return strJson;
    }

    private string getAllEmpLevel()
    {
        //业务角色类
        Chenxin.Lib.House.BLL.DataDictionary bllDic = new Chenxin.Lib.House.BLL.DataDictionary();

        //json数据
        string strJson = "{ txt: '请选择', val: '0' }";

        List<Chenxin.Lib.House.Entity.DataDictionary> lsPosition = bllDic.GetDicList("System.EmpLevel", CurrentUserInfo.CityId);
        //循环列表
        for (int idxCnt = 0; idxCnt < lsPosition.Count; idxCnt++)
        {
            strJson = strJson + ",{ txt: '";
            strJson = strJson + lsPosition[idxCnt].ItemValue;
            strJson = strJson + "', val: '";
            strJson = strJson + lsPosition[idxCnt].ItemValue;
            strJson = strJson + "' }";
        }

        return strJson;
    }

    /// <summary>
    /// 获取公司，通过城市ID
    /// </summary>
    /// <param name="cityId">公司所在城市ID，为null是，返回所有公司</param>
    /// <returns></returns>
    private string GetCompanyByCity(string cityId)
    {
        string where=" 1=1 and DepartProperty=200";
        Chenxin.Lib.Hr.BLL.Hr_DepartmentInfo bll = new Chenxin.Lib.Hr.BLL.Hr_DepartmentInfo();
        if (cityId != null)
        {
            where += " and CityID='" + cityId + "'";
        }
        DataTable dt = bll.GetList(where).Tables[0];

        StringBuilder jsonSb = new StringBuilder();
        jsonSb.Append("{ txt: '请选择', val: '0' }");
        
        foreach (DataRow dr in dt.Rows)
        {
            jsonSb.Append(",{");
            jsonSb.Append("txt:'" + dr["DepartName"].ToString() + "',val:'" + dr["DepartId"].ToString() + "'");
            jsonSb.Append("}");
        }
        return jsonSb.ToString();
    }
    
    //*******************************************
    //功能概要       ：得到人员信息
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：得到人员信息
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-04 
    //*******************************************
    private void searchUserInfo(HttpContext context)
    {
        //参数列表
        System.Collections.Hashtable htParams = new System.Collections.Hashtable();
        //当前参数
        string strParam;

        //条件
        strParam = context.Request.Params["Condition"];
        if (strParam != null & strParam != "")
        {
            htParams.Add("Condition", strParam);
        }
        //工号
        strParam = context.Request.Params["UserCode"];
        if (strParam != null & strParam != "")
        {
            htParams.Add("UserCode", strParam);
        }
        //状态
        strParam = context.Request.Params["Status"];
        //全部或者为空的场合
        if (strParam != null & strParam != "" & strParam != "0")
        {
            htParams.Add("Status", strParam);
        }
        //到职时间（开始）
        strParam = context.Request.Params["ComeDateFrom"];
        if (strParam != null & strParam != "")
        {
            htParams.Add("ComeDateFrom", strParam);
        }
        //到职时间（结束）
        strParam = context.Request.Params["ComeDateTo"];
        if (strParam != null & strParam != null & strParam != "")
        {
            htParams.Add("ComeDateTo", strParam);
        }
        //合同开始时间（开始）
        strParam = context.Request.Params["ContractDateFrom"];
        if (strParam != null & strParam != "")
        {
            htParams.Add("ContractDateFrom", strParam);
        }
        //合同开始时间（结束）
        strParam = context.Request.Params["ContractDateTo"];
        if (strParam != null & strParam != "")
        {
            htParams.Add("ContractDateTo", strParam);
        }
        //离职时间（开始）
        strParam = context.Request.Params["LeaveDateFrom"];
        if (strParam != null & strParam != "")
        {
            htParams.Add("LeaveDateFrom", strParam);
        }
        //离职时间（结束）
        strParam = context.Request.Params["LeaveDateTo"];
        if (strParam != null & strParam != "")
        {
            htParams.Add("LeaveDateTo", strParam);
        }
        //身份证号
        strParam = context.Request.Params["IDNo"];
        if (strParam != null & strParam != "")
        {
            htParams.Add("IDNo", strParam);
        }
        //角色
        strParam = context.Request.Params["RoleId"];
        if (strParam != null & strParam != "" & strParam != "0")
        {
            htParams.Add("RoleId", strParam);
        }
        //职务
        strParam = context.Request.Params["Position"];
        if (strParam != null & strParam != "" & strParam != "0")
        {
            htParams.Add("Position", strParam);
        }
        //虚账号
        strParam = context.Request.Params["IsVirtual"];
        if (strParam != null)
        {
            htParams.Add("IsVirtual", strParam);
        }

        //当前页数
        strParam = (string.IsNullOrEmpty(context.Request["pageindex"])) ? "1" : (int.Parse(context.Request["pageindex"]) + 1).ToString();
        htParams.Add("page", strParam);
        //显示行数
        strParam = (string.IsNullOrEmpty(context.Request["pagesize"])) ? "30" : context.Request["pagesize"];//页记录数
        htParams.Add("rows", strParam);
        

        strParam = context.Request.Params["ConditionType"];
        if (strParam != null & strParam != "")
        {
            string strConditionId = context.Request.Params["ConditionId"];
            if (strParam == "DepartInfo")
            {
                htParams.Add("DepartId", strConditionId);
            }
            else
            {
                htParams.Add("UserId", strConditionId);
            }
        }

        strParam = (string.IsNullOrEmpty(context.Request.Params["ShowType"])) ? "1" : context.Request.Params["ShowType"];
        htParams.Add("show", strParam);

        strParam = (string.IsNullOrEmpty(context.Request["cityid"])) ? CurrentUserInfo.CityId.ToString() : context.Request["cityid"];
        htParams.Add("cityid_s", strParam);
        strParam = (string.IsNullOrEmpty(context.Request["companyid"])) ? CurrentUserInfo.CompanyId.ToString() : context.Request["companyid"];
        htParams.Add("companyid_s", strParam);
        strParam = (string.IsNullOrEmpty(context.Request["areaid"])) ? Guid.Empty.ToString() : context.Request["areaId"];
        htParams.Add("areaid_s", strParam);
        strParam = (string.IsNullOrEmpty(context.Request["departid"])) ? Guid.Empty.ToString() : context.Request["departid"];
        htParams.Add("departid_s", strParam);
        strParam = (string.IsNullOrEmpty(context.Request["userid"])) ? Guid.Empty.ToString() : context.Request["userid"];
        htParams.Add("userid_s", strParam);
        
        try
        {
            Chenxin.Lib.Passport.BLL.Hr_UserInfo blluserinfo = new Chenxin.Lib.Passport.BLL.Hr_UserInfo();
            int count = 0;
            string strHtml = blluserinfo.GetModelListByCoditions(htParams, out count);
            context.Response.Write(string.Format("{{success:'1',msg:'{0}',data:{{count:'{1}',data:'{2}'}}}}", "成功", count, strHtml));
        }
        catch (Exception ex)
        {
            context.Response.Write(string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message));            
        }
        
    }
    

    //*******************************************
    //功能概要       ：匹配条件
    //参数説明       ：context 请求上下文
    //返回值説明     ：无
    //功能詳細       ：匹配条件
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-09 
    //*******************************************
    public void getCondition(HttpContext context)
    {
        StringBuilder strHtml = new StringBuilder();

        string strQuery = context.Request.QueryString["query"];

        try
        {

            Chenxin.Lib.Passport.BLL.Hr_UserInfo bllUserInfo = new Chenxin.Lib.Passport.BLL.Hr_UserInfo();

            System.Collections.ArrayList lsUsersDeparts = bllUserInfo.GetUsersDeparts(strQuery);

            List<Chenxin.Lib.Passport.Entity.Hr_UserInfo> lsUserInfo = (List<Chenxin.Lib.Passport.Entity.Hr_UserInfo>)lsUsersDeparts[0];
            List<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo> lsDepartInfo = (List<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>)lsUsersDeparts[1];

            
            if (lsUserInfo.Count > 0)
            {
                strHtml.Append("<dt>人员</dt>");
                
                //strHtml.Append("<div>");
                //strHtml.Append("<label>人员</label>");
                //strHtml.Append("<br />");
                //strHtml.Append("<ul class='clsMatch'>");

                foreach (Chenxin.Lib.Passport.Entity.Hr_UserInfo lsUser in lsUserInfo)
                {
                    //strHtml.Append("<li>");
                    //strHtml.Append("<div class='clsUserInfo'>");
                    string strShowNm = lsUser.UserName + "(" + lsUser.UserCode+ ")";
                    strHtml.Append("<dd>");
                    strHtml.Append(" <input type=hidden name='hidType' value='UserInfo' />");
                    strHtml.Append(" <input type=hidden name='hidId' value='" + lsUser.UserId.ToString() + "' />");
                    strHtml.Append(" <input type=hidden name='hidNm' value='" + strShowNm + "' />");
                    strHtml.Append(" <a class='clsAUser' href='#'>" + strShowNm + "</a>");
                    strHtml.Append("</dd>");
                    //strHtml.Append("</div>");
                    //strHtml.Append("</li>");
                }
                //strHtml.Append("</ul>");
                //strHtml.Append("</div>");
            }


            if (lsDepartInfo.Count > 0)
            {
                strHtml.Append("<dt>部门</dt>");
                //strHtml.Append("<div>");
                //strHtml.Append("<label>部门</label>");
                //strHtml.Append("<br />");
                //strHtml.Append("<ul class='clsMatch'>");
                foreach (Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo lsDepart in lsDepartInfo)
                {
                    //strHtml.Append("<li>");
                    //strHtml.Append("<div class='clsUserInfo'>");
                    strHtml.Append("<dd>");
                    strHtml.Append(" <input type=hidden name='hidType' value='DepartInfo' />");
                    strHtml.Append(" <input type=hidden name='hidId' value='" + lsDepart.DepartId.ToString() + "' />");
                    strHtml.Append(" <input type=hidden name='hidNm' value='" + lsDepart.DepartName + "' />");
                    strHtml.Append(" <a id='clsAUser' href='#'>" + lsDepart.DepartName + "</a>");
                    strHtml.Append("</dd>");
                    //strHtml.Append("</div>");
                    //strHtml.Append("</li>");
                }
                //strHtml.Append("</ul>");
                //strHtml.Append("</div>");
            }
            
       
          //响应内容
            context.Response.Write(JsonHelper<string>.WriteObject("SUCCESS", strHtml.ToString()));
        }
        catch(Exception ex)
        {
            //错误信息回传
            context.Response.Write(JsonHelper<string>.WriteObject("ERROR", ex.Message));
        }
    }
    
    //*******************************************
    //功能概要       ：用户基本信息数据登录
    //参数説明       ：context 请求上下文
    //返回值説明     ：无
    //功能詳細       ：用户基本信息数据登录
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-07 
    //*******************************************
    public void addUserInfo(HttpContext context)
    {
        /*
        //用户基本信息实体类
        Chenxin.Lib.Passport.Entity.Hr_UserInfo entUserInfo = new Chenxin.Lib.Passport.Entity.Hr_UserInfo();
        //用户基本信息业务类
        Chenxin.Lib.Passport.BLL.Hr_UserInfo bllUserInfo = new Chenxin.Lib.Passport.BLL.Hr_UserInfo();


        //用户Id
        entUserInfo.UserId = Guid.NewGuid();
       
        //用户姓名
        entUserInfo.UserName = context.Request.Params["UserName"];
        //用户类型
        entUserInfo.UserType = Convert.ToInt32(context.Request.Params["UserType"]);
        //性别
        entUserInfo.Sex =Convert.ToInt32(context.Request.Params["Sex"]);
        //证件类型
        entUserInfo.IDType = context.Request.Params["IDType"];
        //证件号码
        entUserInfo.IDNo = context.Request.Params["IDNo"];
        //手机号
        entUserInfo.Mobile = context.Request.Params["Mobile"];
        //家庭电弧
        entUserInfo.HomeTel = context.Request.Params["HomeTel"];
        //地址
        entUserInfo.Address = context.Request.Params["Address"];

        //城市
        entUserInfo.CityId= new Guid(context.Request.Params["City"]);
        //生日
        if (context.Request.Params["BirthDay"] != "")
        {
            entUserInfo.BirthDay = Convert.ToDateTime(context.Request.Params["BirthDay"]);
        }
        //教育程度
        entUserInfo.Education = context.Request.Params["Education"].ToString() == "0" ? "" : context.Request.Params["Education"];
        //部门Id
        entUserInfo.DepartId = new Guid(context.Request.Params["DepartId"]);
        //工作电话
        entUserInfo.OfficeTel = context.Request.Params["OfficeTel"];
        //银行帐号
        entUserInfo.BankNo = context.Request.Params["BankNo"];
        //到职日期
        if (context.Request.Params["ComeDate"] != "")
        {
            entUserInfo.ComeDate = Convert.ToDateTime(context.Request.Params["ComeDate"]);
        }
        //公积金帐号
        entUserInfo.FundCode = context.Request.Params["FundCode"];
        //职务
        entUserInfo.Position =  context.Request.Params["Position"];
        //职级
        entUserInfo.EmpLevel = context.Request.Params["EmpLevel"];
        
        //是否冻结
        entUserInfo.Validate = true;
        //备注
        entUserInfo.Remark = context.Request.Params["Remark"];
        //部门名
        entUserInfo.DepartName = context.Request.Params["DepartName"];
        //城市名
        entUserInfo.CityName = context.Request.Params["CityName"];
        if (context.Request["ConBegin"] != "")
        {
            entUserInfo.ConBegin = Convert.ToDateTime(context.Request["ConBegin"]);
        }
        if (context.Request["ConEnd"] != "")
        {
            entUserInfo.ConEnd = Convert.ToDateTime(context.Request["ConEnd"]);
        }
        if (context.Request["WorkBegin"] != "")
        {
            entUserInfo.WorkAgeBegin = Convert.ToDateTime(context.Request["WorkBegin"]);
        }
        //邮箱
        entUserInfo.Email = context.Request.Params["Email"];
        //公司ID
        entUserInfo.CompanyId = new Guid( context.Request.Params["CompanyId"]);
        //公司名
        entUserInfo.CompanyName= context.Request.Params["CompanyName"];
        
        //操作人员
        entUserInfo.AddPerson = CurrentUserInfo.UserName;
        //操作部门
        entUserInfo.AddDepart = CurrentUserInfo.DepartName;
        //状态
        entUserInfo.Status = 1;
        //密码（暂时固定）
        entUserInfo.Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("111", "MD5");
        //姓名品应首字母
        entUserInfo.Initial = Chenxin.Lib.Utility.InitialHelper.GetChineseSpell(entUserInfo.UserName).Substring(0,1);
        //是否虚拟账号
        entUserInfo.IsVirtual = false;
        //员工编号
        string companyCode = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(entUserInfo.CompanyId).DepartCode;
        string usercode = Chenxin.Lib.Passport.BLL.Hr_UserInfo.GetUserCode(entUserInfo.CompanyId, companyCode);
        entUserInfo.UserCode = usercode;
        //流水号
        entUserInfo.SerialCode = entUserInfo.UserCode.Replace(companyCode, "");
        try
        {
            //用户登录
            string setting = bllUserInfo.Add(entUserInfo);
            context.Response.Write("{success:'1',usercode:'"+usercode+"',setting:'"+setting+"'}");
        }
        catch(Exception ex)
        {
            context.Response.Write("{success:'0',txt:'" + ex.Message + "'}");
        }*/
        
        try
        {
            //用户基本信息业务类
            Chenxin.Lib.Passport.BLL.Hr_UserInfo bllUserInfo = new Chenxin.Lib.Passport.BLL.Hr_UserInfo();
            //用户基本信息实体类
            Chenxin.Lib.Passport.Entity.Hr_UserInfo entUserInfo =
            (Chenxin.Lib.Passport.Entity.Hr_UserInfo)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.Passport.Entity.Hr_UserInfo));

            //用户Id
            entUserInfo.UserId = Guid.NewGuid();

            //操作人员
            entUserInfo.AddPerson = CurrentUserInfo.UserName;
            //操作部门
            entUserInfo.AddDepart = CurrentUserInfo.DepartName;
            //状态
            entUserInfo.Status = 1;
            //密码（暂时固定）
            entUserInfo.Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("111", "MD5");
            //姓名品应首字母
            entUserInfo.Initial = Chenxin.Lib.Utility.InitialHelper.GetChineseSpell(entUserInfo.UserName).Substring(0, 1);
            //是否虚拟账号
            entUserInfo.IsVirtual = false;
            //员工编号
            string companyCode = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(entUserInfo.CompanyId).DepartCode;
            string usercode = Chenxin.Lib.Passport.BLL.Hr_UserInfo.GetUserCode(entUserInfo.CompanyId, companyCode);
            entUserInfo.UserCode = usercode;
            //流水号
            entUserInfo.SerialCode = entUserInfo.UserCode.Replace(companyCode, "");


            bllUserInfo.Add(entUserInfo);

            context.Response.Write(retExecResult(Constants.ExecResult.Succ, "添加成功", ""));
        }
        catch (Exception ex)
        {
            context.Response.Write(retExecResult(Constants.ExecResult.Error, ex.Message, ""));
        }
    }
    
    //*******************************************
    //功能概要       ：删除用户基本信息数据
    //参数説明       ：context 请求上下文
    //返回值説明     ：无
    //功能詳細       ：删除用户基本信息数据
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-07 
    //*******************************************
    public void delUserInfo(HttpContext context)
    {
        //用户Id
        string strUserId = context.Request.Params["UserId"];
        //用户业务类
        Chenxin.Lib.Passport.BLL.Hr_UserInfo bllHrUserInfo = new Chenxin.Lib.Passport.BLL.Hr_UserInfo();

        try
        {
            //用户删除
            bllHrUserInfo.Delete(new Guid(strUserId));
            context.Response.Write(JsonHelper<string>.WriteObject("SUCCESS", ""));
        }
        catch (Exception ex)
        {
            context.Response.Write(JsonHelper<string>.WriteObject("ERROR", ex.Message));
        }
    }

    //*******************************************
    //功能概要       ：得到用户基本信息数据
    //参数説明       ：context 请求上下文
    //返回值説明     ：无
    //功能詳細       ：得到用户基本信息数据
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-07 
    //*******************************************
    public void getUserInfo(HttpContext context)
    {
        try
        {
            string strUserId = context.Request.Params["UserId"];
            //业务类
            Chenxin.Lib.Passport.BLL.Hr_UserInfo bllHrUserInfo = new Chenxin.Lib.Passport.BLL.Hr_UserInfo();
            //实体类
            Chenxin.Lib.Passport.Entity.Hr_UserInfo entHrUserInfo = bllHrUserInfo.GetEntityById(new Guid(strUserId));

            //entHrUserInfo = bllHrUserInfo.GetEntityById(new Guid(strUserId));

            //context.Response.Write(JsonHelper<Chenxin.Lib.Passport.Entity.Hr_UserInfo>.WriteObject("SUCCESS", entHrUserInfo));
            //响应内容
            context.Response.Write(retExecResult(Constants.ExecResult.Succ, "OK", entHrUserInfo));
        }
        catch (Exception ex)
        {
            //context.Response.Write(JsonHelper<string>.WriteObject("ERROR", ex.Message));
            context.Response.Write(retExecResult(Constants.ExecResult.Error, ex.Message, ""));
        }
    }

    //*******************************************
    //功能概要       ：编辑用户基本信息数据
    //参数説明       ：context 请求上下文
    //返回值説明     ：无
    //功能詳細       ：编辑用户基本信息数据
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-07 
    //*******************************************
    public void editUserInfo(HttpContext context)
    {

        try
        {

            //用户基本信息业务类
            Chenxin.Lib.Passport.BLL.Hr_UserInfo bllUserInfo = new Chenxin.Lib.Passport.BLL.Hr_UserInfo();
            //用户基本信息实体类
            Chenxin.Lib.Passport.Entity.Hr_UserInfo entUserInfo =
            (Chenxin.Lib.Passport.Entity.Hr_UserInfo)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.Passport.Entity.Hr_UserInfo));

            Chenxin.Lib.Passport.Entity.Hr_UserInfo entHrUserInfo = bllUserInfo.GetEntityById(entUserInfo.UserId);

            //用户姓名
            entHrUserInfo.UserName = entUserInfo.UserName;
            //用户类型
            entHrUserInfo.UserType = entUserInfo.UserType;
            //性别
            entHrUserInfo.Sex = entUserInfo.Sex;
            //是否冻结
            entHrUserInfo.Validate = entUserInfo.Validate;
            //证件类型
            entHrUserInfo.IDType = entUserInfo.IDType;
            //证件号码
            entHrUserInfo.IDNo = entUserInfo.IDNo;
            //手机号
            entHrUserInfo.Mobile = entUserInfo.Mobile;
            //家庭电弧
            entHrUserInfo.HomeTel = entUserInfo.HomeTel;
            //地址
            entHrUserInfo.Address = entUserInfo.Address;
            //生日
            entHrUserInfo.BirthDay = entUserInfo.BirthDay;
            //教育程度
            entHrUserInfo.Education = entUserInfo.Education;
            //工作电话
            entHrUserInfo.OfficeTel = entUserInfo.OfficeTel;
            //银行帐号
            entHrUserInfo.BankNo = entUserInfo.BankNo;
            //公积金帐号
            entHrUserInfo.FundCode = entUserInfo.FundCode;
            //备注
            entHrUserInfo.Remark = entUserInfo.Remark;
            //合同开始
            entHrUserInfo.ConBegin = entUserInfo.ConBegin;
            //合同结束
            entHrUserInfo.ConEnd = entUserInfo.ConEnd;
            //工龄起始日
            entHrUserInfo.WorkAgeBegin = entUserInfo.WorkAgeBegin;
            
            entHrUserInfo.UpdateTime = DateTime.Now;

            bllUserInfo.Update(entHrUserInfo);

            context.Response.Write(retExecResult(Constants.ExecResult.Succ, "修改成功", ""));
        }
        catch (Exception ex)
        {
            context.Response.Write(retExecResult(Constants.ExecResult.Error, ex.Message, ""));
        }
    }

    //*******************************************
    //功能概要       ：得到用户调动数据
    //参数説明       ：context 请求上下文
    //返回值説明     ：无
    //功能詳細       ：得到用户调动数据
    //作成者         ：he.jifeng 
    //作成日         ：2010-03-08 
    //*******************************************
    public void getTransferInfo(HttpContext context)
    {
        string strUserId = context.Request.Params["UserId"];
    }
        
}